<?php

namespace App\Http\Middleware\Admin;

use Closure;

class Auth
{
    /**
     * Handle an incoming request.
     * 处理传入的请求
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $admin = $request->session()->get('admin');
        if (empty($admin)) {
            return redirect()->route('admin.tologin');
        }

        if ($admin->is_super) {
            return $next($request);
        }

        return $next($request);
    }
}
